

function FFWD_Grid(docElement){
	this.docElement=docElement;
	console_log(this);
	
	$('td',this.docElement).bind('click.c2i',{grid:this},function(p){p.data.grid.col2Input(this);});
}

FFWD_Grid.prototype.bindEvent=function(obj,eventtype,func){
	$(obj).bind(eventtype,{grid:this},function(p){p.data.grid.call(func,this); })
	
}

FFWD_Grid.prototype.col2Input=function(td){
	html=$(td).html();
	padding=parseInt($(td).css('paddingLeft'));
	w=$(td).width()+2*padding;
	h=$(td).height()+2*padding;	
	$(td).html('<input type="text" value="'+html+'" style="width:'+w+';height:'+h+'"  />');
	$(td).addClass('hasinput');
	$(td).unbind('click.c2i');
	
	input=$(':input',td)[0];
	$(input).bind('blur',{grid:this},function(p){p.data.grid.input2Col(this);});
	input.focus();
	
}

FFWD_Grid.prototype.input2Col=function(input){
	value=$(input).prop('value');
	td=$(input).parent();
	$(td).html(value);
	$(td).removeClass('hasinput');
	$(td).bind('click.c2i',{grid:this},function(p){p.data.grid.col2Input(this);});	
}

$(document).ready(function(){
	$('table.ffwd_grid').each(function(){
		new FFWD_Grid(this);		
	});
	
})